﻿
@using Single_SignOn.ResX
@{
    Layout = "~/Areas/Web/Views/Shared/_Layout.cshtml";    
}
@using (Html.BeginForm())
{
    <table style="width: 100%; height: 100%; border: 0;">
        <tr>
            <td style="width: 100%;height: 100%; text-align: center; vertical-align: middle;">
                <div>
                    <div id="content" >
                        <div class="error-summary"></div>
                        <div class="clear"></div>
                        <div class="left">
                            <p></p>
                            <p>
                                <input type="radio" name="radioLogin" id="ADL" value="ADL" checked="checked" />
                                <label>@ResourceTools.GetResource("Resource","rdoADLogin") </label>
                            </p>
                            <p></p>
                            <p>
                                <input type="radio" name="radioLogin" id="SSL" value="SSL" />
                                <label>@ResourceTools.GetResource("Resource","rdoSingleSignOnLogin")</label>
                            </p>
                            <p></p>
                        </div>
                        <div class="center">
                            <button type="button" name="login" id="login" title = '@ResourceTools.GetResource("Resource","ClickToAuthentication")'>
                                <img src="~/Images/asset.gif" alt=" @ResourceTools.GetResource("Resource","ClickToAuthentication") " />
                                &nbsp;&nbsp;&nbsp;&nbsp; @ResourceTools.GetResource("Resource","Login")
                            </button>
                        </div>

                    </div>
                    <!--<div class="clear"></div>
                <div id="form_footer">
                    <lable>@ResourceTools.GetResource("Resource","CopyRight")</lable>
                </div>
                -->
                </div>
            </td>
        </tr>
    </table>
}

<!-- Json passer -->
<div class="display">
    <script type="text/javascript">

        $(document).ready(function () {

            $('#login').click(function () {

                var oKeyDataObj = {
                    "RadioLogin": "" + $('input[name=radioLogin]:checked').val() + ""
                };

                $.ajax({
                    url: '@Url.Action("Login", "Authentication")',
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json; charset=utf-8",
                        data: JSON.stringify(oKeyDataObj),
                        success: function (data, textStatus, xhr) {
                            //At this point I would like to redirect
                            window.location.href = data.redirectToUrl;
                        },
                        error: function (xhr, textStatus, errorThrown) {
                            $(".error-summary").html(xhr.responseText);
                        }
                    });

                    return false;
                });


            });

    </script>
</div>
<!-- Json passer -->
